package com.ewanghuiju.app.ui.shopmail.adapter;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ewanghuiju.app.R;
import com.ewanghuiju.app.component.ImageLoader;
import com.ewanghuiju.app.model.bean.response.CreateShareResponBean;

/**
 * @author sj  qq:751943509
 * @class 创建分享
 * @time 2020/2/20
 */
public class CreateShareAdapter extends BaseQuickAdapter<CreateShareResponBean, BaseViewHolder> {
    public CreateShareAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    protected void convert(BaseViewHolder helper, CreateShareResponBean item) {
        ImageView iv_lab = helper.getView(R.id.iv_select);
        iv_lab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                item.setChecked(!item.isChecked());
                notifyItemChanged(helper.getLayoutPosition());
            }
        });
        if (item.isChecked()) {
//            iv_lab.setImageResource(R.mipmap.icon_share_img_selected);
            ImageLoader.load(mContext, R.mipmap.icon_share_img_selected, iv_lab);
        } else {
//            iv_lab.setImageResource(R.mipmap.icon_share_img_unselected);
            ImageLoader.load(mContext, R.mipmap.icon_share_img_unselected, iv_lab);
        }
        ImageView iv_img = helper.getView(R.id.iv_img);
        ImageLoader.load(mContext, item.getUrl(), iv_img);
    }
}
